/**
 * <copyright>
 * </copyright>
 *
 * $Id$
 */
package warmachinesystem.impl;

import java.util.Collection;

import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.util.EObjectResolvingEList;

import warmachinesystem.Unit;
import warmachinesystem.UnitAttachment;
import warmachinesystem.UnitKind;
import warmachinesystem.WarmachineSystemPackage;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Unit Attachment</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link warmachinesystem.impl.UnitAttachmentImpl#getAttachableUnits <em>Attachable Units</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class UnitAttachmentImpl extends BaseUnitImpl implements UnitAttachment {
	/**
	 * The cached value of the '{@link #getAttachableUnits() <em>Attachable Units</em>}' reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getAttachableUnits()
	 * @generated
	 * @ordered
	 */
	protected EList<Unit> attachableUnits;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected UnitAttachmentImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated NOT
	 */
	@Override
	public UnitKind getKind() {
		return UnitKind.UNIT_ATTACHMENT;
	}
	
	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return WarmachineSystemPackage.Literals.UNIT_ATTACHMENT;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<Unit> getAttachableUnits() {
		if (attachableUnits == null) {
			attachableUnits = new EObjectResolvingEList<Unit>(Unit.class, this, WarmachineSystemPackage.UNIT_ATTACHMENT__ATTACHABLE_UNITS);
		}
		return attachableUnits;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case WarmachineSystemPackage.UNIT_ATTACHMENT__ATTACHABLE_UNITS:
				return getAttachableUnits();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@SuppressWarnings("unchecked")
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case WarmachineSystemPackage.UNIT_ATTACHMENT__ATTACHABLE_UNITS:
				getAttachableUnits().clear();
				getAttachableUnits().addAll((Collection<? extends Unit>)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case WarmachineSystemPackage.UNIT_ATTACHMENT__ATTACHABLE_UNITS:
				getAttachableUnits().clear();
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case WarmachineSystemPackage.UNIT_ATTACHMENT__ATTACHABLE_UNITS:
				return attachableUnits != null && !attachableUnits.isEmpty();
		}
		return super.eIsSet(featureID);
	}

} //UnitAttachmentImpl
